package com.rayboo.example.design.pattern.builder;

public class Computer {

    private String mMainboard;
    private String mDisplayer;
    private String mKeyboard;
    private String mMouse;

    public Computer(String mainboard, String displayer, String keyboard, String mouse) {
        mMainboard = mainboard;
        mDisplayer = displayer;
        mKeyboard = keyboard;
        mMouse = mouse;
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public static class Builder {
        private String mMainboard;
        private String mDisplayer;
        private String mKeyboard;
        private String mMouse;

        public Builder() {
            mMainboard = "默认主板";
            mDisplayer = "默认显示器";
            mKeyboard = "默认键盘";
            mMouse = "默认鼠标";
        }

        public Builder setMainboard(String mainboard) {
            mMainboard = mainboard;
            return this;
        }

        public Builder setDisplayer(String displayer) {
            mDisplayer = displayer;
            return this;
        }

        public Builder setKeyboard(String keyboard) {
            mKeyboard = keyboard;
            return this;
        }

        public Builder setMouse(String mouse) {
            mMouse = mouse;
            return this;
        }

        public Computer build() {
            return new Computer(mMainboard, mDisplayer, mKeyboard, mMouse);
        }
    }

    @Override
    public String toString() {
        return "Computer{" +
                "mMainboard='" + mMainboard + '\'' +
                ", mDisplayer='" + mDisplayer + '\'' +
                ", mKeyboard='" + mKeyboard + '\'' +
                ", mMouse='" + mMouse + '\'' +
                '}';
    }
}
